Skip to content

feat: implemented useValidatorCheck and useManuallyUpdatePoolStatus h…#74

Merged
martinvibes merged 3 commits intoWeb3Novalabs:mainfrom
zachyo:feature/update_pool_status
Jul 31, 2025
Merged

feat: implemented useValidatorCheck and useManuallyUpdatePoolStatus h…#74
martinvibes merged 3 commits intoWeb3Novalabs:mainfrom
zachyo:feature/update_pool_status

Conversation

@zachyo
Copy link
Contributor

@zachyo zachyo commented Jul 24, 2025

Add Manual Pool State Management and Validator Authentication

Overview

This pull request introduces administrative functionality for manual pool state management and validator authentication within the Predifi application. The changes enable authorized validators to manually update pool states when necessary, providing essential administrative control over pool lifecycle management. Closes #69

Changes Made

New Hooks Added

1. useManuallyUpdatePoolState Hook

  • Location: src/app/hooks/useManuallyUpdatePoolState.ts
  • Purpose: Provides functionality to manually update pool states
  • Key Features:
    • Accepts pool ID and new status parameters
    • Handles wallet and contract availability validation
    • Implements proper error handling and loading states
    • Provides success/error callbacks for flexible integration
    • Uses Starknet's Cairo uint256 for pool ID handling
    • Includes transaction waiting and status verification

2. useValidatorCheck Hook

  • Location: src/app/hooks/useValidatorCheck.ts
  • Purpose: Validates whether the connected account has validator permissions
  • Key Features:
    • Reads validator status from the smart contract
    • Returns loading states for UI feedback
    • Provides account address for reference

Constants Update

  • Location: src/constants/functionNames.ts
  • Addition: Added MANUALLY_UPDATE_POOL_STATE constant for consistent function name usage

Technical Implementation

Pool State Management

The updatePoolState function handles the complete workflow:

  1. Validates wallet connection and contract availability
  2. Converts pool ID to Cairo uint256 format
  3. Compiles call data using Starknet's CallData utility
  4. Executes the transaction through the connected account
  5. Waits for transaction confirmation
  6. Provides user feedback through toast notifications

Validator Authentication

The validator check hook integrates with the smart contract's is_validator function to determine user permissions, enabling conditional rendering of administrative features.

Error Handling

Both hooks implement comprehensive error handling:

  • Network connectivity issues
  • Wallet connection problems
  • Contract interaction failures
  • Transaction execution errors

Dependencies

This implementation relies on:

  • @starknet-react/core for blockchain interactions
  • starknet library for Cairo utilities
  • react-hot-toast for user notifications
  • Existing Predifi ABI and contract configurations

Breaking Changes

None. This is an additive change that extends existing functionality without modifying current interfaces.

@martinvibes
Copy link
Contributor

@zachyo can you do a video showcasing how it works

@zachyo
Copy link
Contributor Author

zachyo commented Jul 30, 2025

Created mock UI to test the manually_update_pool_state functionality since my wallet doesn't have validator/admin permissions on the contract. The "Caller not authorized" error prevents testing the actual transaction flow, so this mock implementation allows us to verify the frontend integration, parameter serialization, and UI interactions work correctly.

This bypasses the contract's access control to demonstrate how the feature would work for authorized users. The enum serialization and CallData compilation have been tested and should work properly once authorized with proper permissions. Remember to connect with a validator wallet to see button.

Adding video demo to show the complete flow and UI behavior.
Loom video

Screenshot from 2025-07-30 20-59-05

@martinvibes
Copy link
Contributor

@zachyo kindly fix conflict

@zachyo
Copy link
Contributor Author

zachyo commented Jul 31, 2025

Conflict fixed @martinvibes

@martinvibes
Copy link
Contributor

@zachyo pls check your TG
i dmed you

@martinvibes martinvibes merged commit 279d855 into Web3Novalabs:main Jul 31, 2025
1 check passed
@martinvibes
Copy link
Contributor

Lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Frontend] implement Manually Update Pool Status fucntion

3 participants